package com.addcn.caruimodule.text;

import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.UnderlineSpan;
import android.util.AttributeSet;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;

/**
 * Created by 10528 on 2018/11/13.
 */

public class UnderLineTextView extends AppCompatTextView {
    public UnderLineTextView(Context context) {
        super(context);
    }

    public UnderLineTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public UnderLineTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void setText(CharSequence text, BufferType type) {
        SpannableString sb= SpannableString.valueOf(text);
        sb.setSpan(new UnderlineSpan(),0, text.length(),Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        super.setText(sb, type);
    }
}
